import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.bj58.argo.Argo;

public class TestUtil {
	static{
		 PropertyConfigurator.configure(Argo.getConfigFolder()+"/IESendlog4j.properties");
	}
	static Logger log4j =  Logger.getLogger("IESendTaskLog");
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		LogTest.log4j.info("log4j debug");
		printLog();
//		checkFormula();
//		String s=";a;b;; ";
//		System.out.println(Arrays.asList(s.split(";")));
//		System.out.println(s.split(";").length);
//		String[] s={"fsdafsa","fgdrgf"};
//		System.out.println(s);
//		String startDate = "2014-07-28";
//		String endDate = "2014-08-05";
//		if(checkParam(startDate,endDate)){
//			System.out.println(startDate.contains("-"));
//			System.out.println(endDate.contains("-"));
//			if(!startDate.contains("-"))
//				startDate=DateUtil.getStringDate(DateUtil.strToDate(startDate, "yyyyMMdd"),"yyyy-MM-dd");
//			if(!endDate.contains("-"))
//				endDate=DateUtil.getStringDate(DateUtil.strToDate(endDate, "yyyyMMdd"),"yyyy-MM-dd");
//			System.out.println(startDate+"---"+endDate);
//		}else{
//			return;
//		}
//		
//		DecimalFormat df = new DecimalFormat("0.00");
//		double num_one = Double.valueOf(df.format(null));
//		System.out.println(num_one);
		
	}
	  public static void printLog(){
//        BasicConfigurator.configure();
//        PropertyConfigurator.configure(PathUtil.getWFNamespaceFolder()+"/IESendlog4j.properties");
//         
//        DOMConfigurator.configure("");
         
        log4j.debug("log4j debug");
        log4j.info("log4j info");
        log4j.warn("log4j warn");
        log4j.error("log4j error");
        log4j.fatal("log4j fatal");
        log4j.fatal("exception ", new NullPointerException());
    }
	
	public static boolean checkParam(String startDate,String endDate){
		Pattern p = Pattern.compile("^((\\d{8})|(\\d{4}-\\d{2}-\\d{2}))$");
		Matcher m=p.matcher(startDate);
		if(!m.matches()){
			System.out.println("************************************************");
			System.out.println("Usage: please input params: startDate [endDate]");
			System.out.println("for example: 2013-01-01 2013-01-06  or  20130106");
			System.out.println("************************************************");
			return false;
		}
		m=p.matcher(endDate);
		if(!m.matches()){
			System.out.println("************************************************");
			System.out.println("Usage: please input params: startDate [endDate]");
			System.out.println("for example: 2013-01-01 2013-01-06  or  20130106");
			System.out.println("************************************************");
			return false;
		}
		System.out.println(startDate+"---"+endDate);
		return true;
	}
	
	public static void checkFormula(){
		System.out.println(StringUtils.isNumeric("12.350"));
//		StringBuffer sb = new StringBuffer();
		String formula="A/A+G+J+A+M+P+S+V+Y+AB+AE+AH";
		Pattern p = Pattern.compile("(^|\\W)(A)(\\W|$)");
		Matcher m=p.matcher(formula);
//		System.out.println(m.matches());
		while(m.find()){
			StringBuffer sb = new StringBuffer();
			m.appendReplacement(sb, m.group(1)+"125"+m.group(3));
			System.out.println(m.group(1)+"---"+m.group(2)+"---"+m.group(3));
			m.appendTail(sb);
			formula=sb.toString();
			System.out.println(formula);
			m=p.matcher(formula);
		}
		System.out.println(formula);
	}
}
